home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group02b.txt
/
000019_icon-group-sender_Mon Aug 19 13:10:34 2002.msg
< prev
next >
Wrap
Internet Message Format
|
2003-01-02
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id g7JKAVk14542
for icon-group-addresses; Mon, 19 Aug 2002 13:10:31 -0700 (MST)
Message-Id: <200208192010.g7JKAVk14542@baskerville.CS.Arizona.EDU>
Date: Mon, 19 Aug 2002 15:56:04 +1200 (NZST)
From: "Richard A. O'Keefe" <ok@cs.otago.ac.nz>
To: icon-group@cs.arizona.edu, jenjhiz@yahoo.com
Subject: Re: What about "Expressions?" (was Re: Icon Wish List)
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
jenjhiz@yahoo.com (Gene Kahn) wrote:
This is not without its advantage, of course. In particular, in terms
of readability, I find that explicit variables allow my mind to
'close' (I'm not using it in the technical sense of "closure")
previous statements. On the other hand, in reading s-expression
languages like Lisp and Scheme, I find that I have to hold in my mind
too many _unstated_ intermediate results before I find what the
expression is all about.
You may be reading them in the wrong direction.
FORTRAN-like
The man kicked the dog.
The dog chased the cat.
The cat bit the mouse.
The mouse died.
LISP-like (in infix notation)
The mouse the cat the dog the man kicked chased bit died.
As a Lisp programmer, I must say that doesn't look Lisp-like to me.
Remember, Lisp puts the "verb" FIRST.
Let's have a form (the (Variable) Condition) which binds Variable inside
Condition and returns the thing that satifies Condition.
;; 'the' is reserved in Common Lisp, so this must be Scheme!
(let* ((H (the (H) (is-man H)))
(D (the (D) (and (is-dog D) (kicked H D))))
(C (the (C) (and (is-cat C) (chased D C))))
(M (the (M) (and (is-mouse M) (bit C M)))))
(died M))
This could also be written
(died (the (M) (and (is-mouse M)
(was bit M (the (C) (and (is-cat C)
(was chased C (the (D) (and (is-dog D)
(was kicked D (the (H) (is-man H))))))))))))
where (define (was f x y) (f y x))
As a Lisp programmer, I wouldn't be satisifed with either of these.
I'd extend "the" to
;; new form
(the (Variable Type) Cond1 ... Condk)
=> ;; old form
(the (Variable) (and (is-Type Variable) Cond1 ... Condk))
and write
(let* ((H (the (man H) #t))
(D (the (dog D) (kicked H D)))
(C (the (cat C) (chased D C)))
(M (the (mouse M) (bit C M))))
(died M))
or
(died (the (mouse M) (was bit M
(the (cat C) (was chased C
(the (dog D) (was kicked D
(the (man H)))))))))
"has died the mouse that was bit by the cat that was chased by
the dog that was kicked by the man".
Of course, variable-less, assignment-less languages have advantages.
Indeed. So of course does Icon. The rule is always to use the language
that best fits the easiest way to think correctly about the problem, and
then translate into whatever your boss forces you to use.